import Vue from 'vue'
import Router from 'vue-router'
import iView from 'iview'
import Layout from '@/components/layout.vue'
import Home from '@/views/home.vue'

Vue.use(Router, iView)

const router = new Router({
	mode: 'history',
	routes: [
		{
			path: '/',
			component: Layout,
			children: [
				{
					path: '/',
					name: 'home',
					meta: {
						title: '首页'
					},
					component: () =>
						import('@/views/home')
				},
				{
					path: 'setting',
					name: 'setting',
					meta: {
						title: '设置'
					},
					component: () =>
						import('@/views/setting')
				}
			]
		}
	]
})

router.beforeEach((to, from, next) => {
	iView.LoadingBar.start()
	next()
})

router.afterEach((transition) => {
	iView.LoadingBar.finish()
})

export default router
